/**
 * 
 */

function initAdTable(path,page){
	$.post(path+"advertiseAction_list.action",{
		"page":page
	},function(result){
		result=eval('('+result+')');
		$("#news_databody").empty();
		$("input[type=checkbox]").removeAttr("checked");
		if(result.rescode=='100'){  
			var newsList=result.data;
			for(var i=0;i<newsList.length;i++){
				var news=newsList[i];   
				/*var $e=$('<tr><td><input type="checkbox" value="'+news.uuid+'" class="logch"></td><td>'+news.title+'</td><td>'+news.subtitle+'</td><td>'+moment(news.createTime).format("20YY年MMMDo hh:mm:ss")+'</td><td>'+moment(news.newsTime).format("20YY年MMMDo hh:mm:ss")+'</td><td>'+news.sumary+'</td><td><a href="javascript:shownewdetails()" class="btn btn-warning">查看详情</a><a href="javascript:editnews()" class="btn btn-primary" style="margin-left:10px;">编辑</a></td></tr>');*/
				var $e=$("<tr><td><input type='checkbox' value='"+news.uuid+"' class='logch'></td><td>"+news.name+"</td><td>"+news.money+"</td><td>"+news.ext+"</td><td>"+news.address+"</td><td>"+news.adStatus+"</td><td>"+moment(news.adDate).format('20YY年MMMDo')+"</td><td>"+moment(news.enDate).format('20YY年MMMDo')+"</td><td>"+news.adCount+"</td></tr>");
				$("#news_databody").append($e); 
			}
			initPages(result.pagebean.curPage,result.pagebean.totalPages);
			 
		}else{
			alertError("操作失败");
		}
	});
}

function delAds(path){
	$.post(path+"advertiseAction_del.action",{
		ids:getChecked()
	},function(result){
		result=eval('('+result+')');
		if(result.rescode=='100'){
			initAdTable(path,1); 
			showSucMsg(result.msg);
		}else{
			showWarnMsg(result.msg);
		}
	});
}

/* 获取所有选中项的id字符串   */
function getChecked() {  
	var ids="";
	$("input[type=checkbox]").each(function() {
		if ($(this).prop("checked")) {
			ids+=$(this).val()+",";
		} 
	});
	return ids.substr(0,ids.length-1);
}